package org.jiamandan.com.strategy.impl.tram.listener;

import io.netty.channel.ChannelHandlerContext;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jiamandan.com.constant.BizConstant;
import org.jiamandan.com.constant.JSYConstant;
import org.jiamandan.com.dto.JsyBasicDto;
import org.jiamandan.com.strategy.impl.tram.IJSYDZBasicListener;
import org.jiamandan.com.utils.JsyObjectUtil;
import org.springframework.stereotype.Service;


@Service(value = JSYConstant.Service.CMD_JSY_T00202_SERVICE)
@AllArgsConstructor
@Slf4j
public class JSYUpdateTimeListener implements IJSYDZBasicListener {

    @Override
    public void doExecute(String payload, ChannelHandlerContext client) throws Exception {
        log.info("JMD-JSY设备更新充电时间应答(CMD = T00202)：" + payload);
        JsyBasicDto jsyBasicDto = JsyObjectUtil.parse(payload);
        String[] items = StringUtils.split(jsyBasicDto.getData(), BizConstant.separator);
        log.info("JMD-JSY更新充电时间:订单号:"+Long.parseLong(items[0],16)+"端口号"+items[1]+"是否成功:"+(items[2].equals("01")?"成功":"失败"));
    }
}
